package com.xxkk.spring_boot_web.utils;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class SignTool {

    /**
     * key=val&key2=val
     *
     * @param map ,
     * @return key=val&key2=val 过滤str == null || str.trim().isEmpty();
     */
    public static String get_ori_sign(Map<String, Object> map) {
        TreeMap<String, Object> treeMap = new TreeMap<>(map);
        StringBuilder sb = new StringBuilder();
        Set<String> keys = treeMap.keySet();
        for (String key : keys) {
            Object value = treeMap.get(key);
            if (value == null || "".equals(value))
                continue;
            sb.append(key).append("=").append(value).append("&");
        }
//        sb.deleteCharAt(sb.length() - 1);// del the end of "&" //cancel
        return sb.toString();
    }
}
